package com.etl.dataflow.scheduler.admin.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.etl.dataflow.scheduler.admin.validation.Add;
import com.etl.dataflow.scheduler.admin.validation.Update;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 数据源实体
 * </p>
 *
 * @author dx
 * @since 2022-04-23
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("dataflow_datasource")
public class DataflowDatasource implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键,使用ID_WORKER策略,全局唯一ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @NotNull(groups = Update.class)
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long id;

    /**
     * jdbc驱动全类名
     */
    @TableField("jdbc_driver")
    @NotBlank(groups = {Add.class})
    private String jdbcDriver;

    /**
     * IP地址
     */
    @TableField("host")
    @NotBlank(groups = {Add.class})
    private String host;

    /**
     * 端口号
     */
    @TableField("port")
    @NotNull(groups = {Add.class})
    private Integer port;

    /**
     * 用户名
     */
    @TableField("user")
    @NotBlank(groups = {Add.class})
    private String user;

    /**
     * 密码
     */
    @TableField("pwd")
    @NotBlank(groups = {Add.class})
    private String pwd;

    /**
     * 模式名
     */
    @TableField("schema_name")
    @NotBlank(groups = {Add.class})
    private String schemaName;

    /**
     * 别名
     */
    @TableField("nickname")
    @NotBlank(groups = Add.class)
    private String nickname;

    /**
     * 创建用户id
     */
    @TableField("creator_id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long creatorId;

    /**
     * 插入时间
     */
    @TableField(value = "idt", fill = FieldFill.INSERT)
    private LocalDateTime idt;

    /**
     * 更新时间
     */
    @TableField(value = "udt", fill = FieldFill.UPDATE)
    private LocalDateTime udt;
}
